<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #zuihou {
            font-size: 10px;
        }

        #tijiao {
            text-align: center;
        }

        #kj {
            border-right: 2px solid black;
            border-left: 2px solid black;
            width: 300px;
            height: 400px;
            text-align: center;
            margin: 0 auto;
            
        }

        span {
            padding: 20px;
        }

    </style>
</head>

<body>
    <div id="kj">
        <img src=https://lims.pkufh.com/img/pkufh/logo.jpg alt="" width="300px">
        <span id="box">注册</span><span id="box1">登录</span><br>
        <div id="box3">
            <input type="text" id="username" placeholder="真实姓名"><br>
            <input type="text" id="idCode" placeholder="身份证号"><br>                                                       
            <input type="text" id="email" placeholder="邮箱"><br>
            <input type="text" id="danwei" placeholder="请选择单位"><br>
            <input type="text" id="keshi" placeholder="请选择科室"><br>
            <input type="text" id="phone" placeholder="手机号"><br>
            <input type="text" id="password" placeholder="密码"><br>
            <input type="text" id="Dpassword" placeholder="请重新输入密码"><br>
            <input type="text" id="sex" placeholder="性别"><br>
             <input type="submit" id="tijiao" placeholder="注册"><br>
            <input type="checkbox" id="tongyi">

            <div id="zuihou">阅读并同意 《服务协议》</div>
        </div>
        <div id="box4" style="display: none;">
            <input type="text" id="Ephone" placeholder="账号/手机号"><br>
            <input type="text" id="Epassword" placeholder="密码"><br>
            <input type="submit" id="denglu">
        </div>
    </div>
    <script src="./jquery-3.7.1.js"></script>
    <script>
        $("#tijiao").click(function () {
            $.ajax({
                url: "http://172.16.106.87:8080/UserEnroll",
                type: "get",
                data: {
                    phone: $("#phone").val(),
                    username: $("#username").val(),
                    password: $("#password").val(),
                    sex: $("#sex").val(),
                    idCode: $("#idCode").val(),
                    email: $("#email").val(),

                },
                success: function (out) {
                   console.log(out);
                   
                }
            })
        })
        $("#box1").click(function () {
            $("#box3").hide()
            $("#box4").show()
        })
        $("#box").click(function () {
            $("#box3").show()
            $("#box4").hide()
        })
        $("#denglu").click(function(){
            
            $.ajax({
                url:"http://172.16.106.87:8080/login",
                type:"get",
                data:{
                    phone:$("#Ephone").val(),
                    password:$("#Epassword").val(),
                },
                success:function(e){
                    console.log(e);
                    if(e.code==200){
                        alert("登录成功")
                        localStorage.setItem("userlist",JSON.stringify(e))
                        

                        
                    }else{
                        alert("登录失败")
                    }
            }
            })
           
        })
    </script>
</body>

</html>